package com.mohammad.fun.dtpkrisgethin;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.os.Vibrator;
import android.view.View;
import android.widget.TextView;

public class shoulder extends Activity {
	
	
	
	TextView timer_shoulder_1;
	
	//Vibration stuff
	Vibrator mVibrator;
	long[] patternVibrate = { 0, 300, 100,300,100,300 };
	
	CountDownTimer Timer;
	Intent intent;

	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.shoulder);
		
		//Getting the URL to work
		String video_path = "http://www.youtube.com/watch?v=gVSX3R7_Wqg";
        Uri uri = Uri.parse(video_path);

        // With this line the youtube application, if installed, will launch immediately.
        // Without it you will be prompted with a list of the application to choose.
        uri = Uri.parse("vnd.youtube:"  + uri.getQueryParameter("v"));

        intent = new Intent(Intent.ACTION_VIEW, uri);

		timer_shoulder_1 = (TextView) findViewById(R.id.timer_shoulder_1);
		// Get instance of Vibrator from current Context
    	mVibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
		
		// The current time can also be taken from "System.currentTimeMillis();"
    	Timer = new CountDownTimer(4500, 1000) {
            public void onTick(long millisUntilFinished) {
            	timer_shoulder_1.setText((millisUntilFinished / 1000) + " Sec");
            }

            public void onFinish() {
            	
            	timer_shoulder_1.setText("DONE !");
            	
            	// Vibrate for the pattern only one time
            	mVibrator.vibrate(patternVibrate, -1);
            }
         };

	}
	 public void btn_startTimer (View v){
		Timer.start();
     }
	 
	 public void btn_watchVideo (View v){
		 startActivity(intent);
	 }

}
